<?php
namespace app\admin\controller;
use think\Db;
//用户管理

class Users extends Base{
	//用户列表
	public function user_list(){  
		$name		=!empty(input('name')) ? input('name') : '';
		$stime		=!empty(input('stime')) ? input('stime') : '';
		$etime		=!empty(input('etime')) ? input('etime') : '';
		if(!empty($name)){
			$map['le.name']=['like','%'.$name.'%'];	
		} 

		$map['le.del'] = 0;

    	$rel=Db::name('users')
        ->alias('le')
        ->join('level u', 'le.id=u.uid','LEFT')
		->where($map)
		->field('le.id as ids,le.integral,le.name,le.wechatname,le.wechatphone,le.stat,le.ctime,le.makecouponnum,le.utime,u.levelnum')
		->order('le.ctime desc,le.id desc')
		->paginate(10,false,['query'=>[
			'le.stime'		=>$stime,
			'le.etime'		=>$etime
		]]);
    	//print_r($rel);exit;
		$this->assign('data',$rel);
		$this->assign('page',$rel->render());
		$this->assign('empty',"<tr><td class='empty' colspan='10'>当前没有数据 </td></tr>");

		return $this->fetch();
	}
	//删除用户
	public function del(){
	$id = input('post.id');
	//print_r($id);die;
    $rel = Db::name('users')->where(array('id'=>$id))->update(['del' => '1']);  
	if(!$rel){
	  return rel(-1,'删除失败');
	}else{
	  return rel(1,'删除成功');
	}
}
	//租客列表
//	public function tenant_list(){
//		echo 1;
//	}
}
